<%@ page import="com.ld.businesscard_manage.bean.BusinessCard" %>
<%@ page import="com.ld.businesscard_manage.service.impl.UserServiceImpl" %>
<%@ page import="com.ld.businesscard_manage.service.UserService" %>
<%@ page import="com.ld.businesscard_manage.service.impl.BusinessCardServiceImpl" %>
<%@ page import="com.ld.businesscard_manage.service.BusinessCardService" %>
<%@ page import="com.ld.businesscard_manage.service.RecyleService" %>
<%@ page import="com.ld.businesscard_manage.service.impl.RecyleServiceImpl" %>
<%@ page import="com.ld.businesscard_manage.bean.User" %><%--
  Created by IntelliJ IDEA.
  User: 刘邓
  Date: 2023-06-10
  Time: 14:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>永久删除名片</title>
</head>
<body>
<%!
  private BusinessCardService cardService = new BusinessCardServiceImpl();
  private RecyleService recyleService = new RecyleServiceImpl();
%>
<%
  User user = (User)(session.getAttribute("user"));
  int id = Integer.parseInt(request.getParameter("id"));
  BusinessCard card = cardService.getCardById(id);
  if(card.getValid() == 2){
    out.println("<h1>无法删除，可能该项已经删除</h1>");
  }else if(card.getValid() == 1){
    int i = cardService.deletedCardById(id);
    int j = recyleService.deleteRecyleByCardId(id);
    if (i == 0 || j == 0) {
      out.println("删除失败,请稍后重试<br></br>");
    } else {
      out.println("删除成功<br></br>");
    }
  }else {
    int i = cardService.deletedCardById(id);
    if (i == 0) {
      out.println("删除失败,请稍后重试<br></br>");
    } else {
      out.println("删除成功<br></br>");
    }
  }
  if(user.getStatus() == 1) {
    out.println("<a href='/home/manageCard.jsp'>返回名片管理页面</a>");
  }else {
    out.println("<a href='/home/myCard.jsp'>返回个人名片管理页面</a>");
  }
%>
</body>
</html>